<template>
	<view class="padding-bottom-lg">
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">
				<view class="custom-title">机构/团体基本信息</view>
			</block>
		</cu-custom>
		<view class="progress1 padding-top-32">
			<view class="progress-circle-1">
				<view class="complate-content">
					<view class="uncomplate-content"></view>
				</view>
				<text class="progress-text">工商信息</text>
			</view>
			<view class="progress-line1"></view>
			<view class="progress-circle-gray">
				<text class="progress-circle-number">2</text>
				<text class="progress-text text-767879">联系信息</text>
			</view>
		</view>
		<view class="margin-32 padding-32 bg-white radius-48">
			<form @submit="toSubmit">
				<view class="basic-qy-name">机构/团体名称：</view>
				<input class="basic-qy-input" v-model="company_name" :disabled="isUpdate" placeholder="请输入企业名称" name="input"></input>
				
				<view class="basic-update-title padding-top-32">
					组织机构代码证/登记证书复印件：
				</view>
				<view @click="ChooseImage(1)" class="yyzz-content flex align-center justify-center">
					<view class="yyzz flex align-center justify-center" :style="{backgroundImage:`url(${zhizhao_url})`}">
						<view class="camera-content flex align-center justify-center">
							<image src="https://txr001.zthj.net/static/camera.png" class="camara-img"></image>
						</view>
					</view>
				</view>
				<view class="padding-top-32 update-info">
					<view>注:1.请上传组织机构代码证/登记证书复印件,JPG或PNG格</view>
					<view class="padding-left">式,大小不超过5MB,拍摄时确保内容完整,字体清晰,亮度均匀；</view>
					<view class="padding-left">2.营业执照信息必须与工商信息一致;</view>
					<view class="padding-left">3.营业执照必须加盖企业公章。</view>
				</view>
				
				<view class="basic-qy-name padding-top-48">统一社会信用代码：</view>
				<input class="basic-qy-input margin-top" placeholder="请输入代码" v-model="taxpayer_Identification_number"
					name="input"></input>
				
				<view class="basic-qy-name padding-top-48">注册地址：</view>
				<input class="basic-qy-input" placeholder="请输入注册地址" v-model="registered_address" name="input"></input>
				
				
				<view class="basic-qy-name padding-top-48">机构/团体类型：</view>
				<radio-group class="block " @change="tradeChange">
					<view class="padding-top-lg padding-bottom">
						<view class="flex align-start">
							<view class="flex-sub flex justify-start align-center">
								<radio value="13" :checked="trade==13" style="transform:scale(0.8)"></radio>
								<text class="basic-radio-title">机关</text>
							</view>
							<view class="flex-sub flex justify-start align-center">
								<radio value="14" :checked="trade==14" style="transform:scale(0.8)"></radio>
								<text class="basic-radio-title">事业单位</text>
							</view>
						</view>
						<view class="flex padding-top-40 align-start">
							<view class="flex-sub flex justify-start align-start">
								<radio value="15" :checked="trade==15" style="transform:scale(0.8)"></radio>
								<text class="basic-radio-title margin-top-6">社会团体（协会等）</text>
							</view>
							<view class="flex-sub flex justify-start align-center">
								<radio value="12" :checked="trade==12" style="transform:scale(0.8)"></radio>
								<text class="basic-radio-title">其他</text>
							</view>
						</view>
					</view>
				</radio-group>
				
				<view class="basic-qy-name padding-top-48">实际经营地址：</view>
				<input class="basic-qy-input" placeholder="请输入实际经营地址" v-model="business_address" name="input"></input>
				
				<view class="padding flex flex-wrap justify-center align-center">
					<button class="cu-btn round submit-btn" form-type="submit">下一步</button>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				company_name: '',
				leader: '',
				taxpayer_Identification_number: '',
				trade: 1,
				trade_notes: '',
				registered_address: '',
				business_address: '',
				mobile: '',
				email: '',
				org_type: 1,
				trade_status: true,
				id: 0,
				isUpdate: false,
				zhizhao_url: 'https://txr001.zthj.net/static/zs.png',
				shouquan_url: 'https://txr001.zthj.net/static/sqs.png',
				renzheng_id: 0
			}
		},
		onLoad(e) {
			if (e.id) {
				this.id = e.id;
				this.isUpdate = true;
				this.getInfo(e.id);
			}
		},
		methods: {
			toSubmit() {
				// if (!this.company_name) {
				// 	uni.showToast({
				// 		title: '请输入企业名称',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (this.trade == 12 && !this.trade_notes) {
				// 	uni.showToast({
				// 		title: '请输入所属行业',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (!this.taxpayer_Identification_number) {
				// 	uni.showToast({
				// 		title: '请输入组织机构代码或统一社会信用代码',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (!this.registered_address) {
				// 	uni.showToast({
				// 		title: '请输入注册地址',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (!this.business_address) {
				// 	uni.showToast({
				// 		title: '请输入实际经营地址',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (!this.leader) {
				// 	uni.showToast({
				// 		title: '请输入法人代表姓名',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// let mobilereg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
				// if (!this.mobile) {
				// 	uni.showToast({
				// 		title: '请输入手机号',
				// 		icon: 'none'
				// 	})
				// 	return
				// }else if(!mobilereg.test(this.mobile)){
				// 	uni.showToast({
				// 		title: '请输入正确的手机号',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// let email_reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
				// if (!this.email) {
				// 	uni.showToast({
				// 		title: '请输入邮箱',
				// 		icon: 'none'
				// 	})
				// 	return
				// }else if(!email_reg.test(this.email)){
				// 	uni.showToast({
				// 		title: '请输入正确的邮箱',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// let url = "https://qd.zthj.net/api/userinfo/addBasic";
				// if (this.id != 0) {
				// 	url = "https://qd.zthj.net/api/userinfo/updateBasic";
				// }
				// uni.request({
				// 	url: url,
				// 	data: {
				// 		user_id: uni.getStorageSync('user_id'),
				// 		ctype: 1,
				// 		company_name: this.company_name,
				// 		leader: this.leader,
				// 		taxpayer_Identification_number: this.taxpayer_Identification_number,
				// 		trade: this.trade,
				// 		trade_notes: this.trade_notes,
				// 		registered_address: this.registered_address,
				// 		business_address: this.business_address,
				// 		mobile: this.mobile,
				// 		email: this.email,
				// 		org_type: this.org_type,
				// 		id: this.id
				// 	},
				// 	method: "POST",
				// 	success: (res) => {
				// 		console.log(res.data);
				// 		if (res.data.code == 1) {
				// 			setTimeout(() => {
				// 				uni.showToast({
				// 					title: '提交成功！',
				// 					icon: 'none'
				// 				});
				// 				if (this.id == 0) {
				// 					setTimeout(() => {
				// 						uni.hideToast();
				// 						//关闭提示后跳转
				// 						uni.navigateTo({
				// 							url: "/pages/company/success?type=1"
				// 						});
				// 					}, 1500)
				
				// 				}
				// 			}, 0);
				
				
				// 		} else {
				// 			uni.showToast({
				// 				title: '该企业您已提交过相关信息！',
				// 				icon: 'none'
				// 			})
				// 		}
				// 	}
				// });
				uni.navigateTo({
					url:"/pages/mine/groups/concactInfo"
				})
			},
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			},
			tradeChange(e) {
				if (e.detail.value == 12) {
					this.trade_status = false;
				} else {
					this.trade_status = true;
				}
				this.trade = e.detail.value;
			},
			jigouChange(e) {
				this.org_type = e.detail.value;
			},
			getInfo: function(id) {
				let that = this;
				uni.request({
					url: 'https://qd.zthj.net/api/userinfo/basicdetail', //仅为示例，并非真实接口地址。
					data: {
						id: id
					},
					success: (res) => {
						console.log(res.data);
						this.company_name = res.data[0].company_name;
						this.trade = res.data[0].trade;
						this.trade_notes = res.data[0].trade_notes;
						this.org_type = res.data[0].org_type;
						this.taxpayer_Identification_number = res.data[0].taxpayer_Identification_number;
						this.registered_address = res.data[0].registered_address;
						this.business_address = res.data[0].business_address;
						this.leader = res.data[0].leader;
						this.mobile = res.data[0].mobile;
						this.email = res.data[0].email;
					}
				});
			}

		}
	}
</script>
<style scoped>
	input{
		color: black;
	}
	.progress-line1{
		width: 286rpx !important;
	}
</style>